#ifndef _MYCOMPLEX_H
#define _MYCOMPLEX_H

#include <iostream>

class mycomplex
{
public:
    explicit mycomplex(double real, double imaginary = 0)
        : m_real(real), m_imaginary(imaginary) {
    }
    mycomplex &operator+=(const mycomplex &other) {
        m_real += other.m_real;
        m_imaginary += other.m_imaginary;
        return *this;
    }
    /* ++i = 10 is allowed */
    mycomplex &operator++() {
        ++m_real;
        return *this;
    }
    /* i++ = 10 is not allowed */
    const mycomplex operator++(int) {
        mycomplex temp(*this);
        ++*this;
        return temp;
    }
    /* Define output as a function, so that a derived class can override it if exists */
    std::ostream &print(std::ostream &os) const {
        return os << "(" << m_real << "," << m_imaginary << ")";
    }
private:
    double m_real;
    double m_imaginary;
};

const mycomplex operator+(const mycomplex &lhs, const mycomplex &rhs)
{
    mycomplex ret(lhs);
    ret += rhs;
    return ret;
}

std::ostream &operator<<(std::ostream &os, const mycomplex &c)
{
    return c.print(os);
}

#endif
